{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d17e8cc8-8f5f-4090-86af-753bdc70e7b1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl\n",
    "from perspective.widget import PerspectiveWidget"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "0c531083-bcd9-4b51-a7fb-3d5282b9fdc2",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = pl.read_parquet(\"new_share.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1c026982-5184-4ae6-ad66-97565befd988",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2 = pl.read_parquet(\"stock_basic.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "173ad8f3-e0bb-47ac-81e8-5bd514ccd677",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2 = d2.with_columns(\n",
    "    list_date=pl.col.list_date.str.to_date(\"%Y%m%d\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "7c35d932-4768-40ac-946a-c0f650ba78f0",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = d1.with_columns(\n",
    "    ipo_date=pl.col.ipo_date.str.to_date(\"%Y%m%d\"),\n",
    "    issue_date=pl.col.issue_date.str.to_date(\"%Y%m%d\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "a4ad5b9a-1b4b-421d-a746-574acb3f6905",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "Unknown input type TypeId(0xa2ed08c824384bb500e5c2441768fa6a)",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mValueError\u001b[39m                                Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[11]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mPerspectiveWidget\u001b[49m\u001b[43m(\u001b[49m\u001b[43md1\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mD:\\Anaconda\\envs\\week07\\Lib\\site-packages\\perspective\\widget\\widget.py:156\u001b[39m, in \u001b[36mPerspectiveWidget.__init__\u001b[39m\u001b[34m(self, data, index, limit, binding_mode, **kwargs)\u001b[39m\n\u001b[32m    153\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m limit \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m    154\u001b[39m     \u001b[38;5;28mself\u001b[39m._options.update({\u001b[33m\"\u001b[39m\u001b[33mlimit\u001b[39m\u001b[33m\"\u001b[39m: limit})\n\u001b[32m--> \u001b[39m\u001b[32m156\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mload\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_options\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mD:\\Anaconda\\envs\\week07\\Lib\\site-packages\\perspective\\widget\\widget.py:161\u001b[39m, in \u001b[36mPerspectiveWidget.load\u001b[39m\u001b[34m(self, data, **options)\u001b[39m\n\u001b[32m    159\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\"Load the widget with data.\"\"\"\u001b[39;00m\n\u001b[32m    160\u001b[39m \u001b[38;5;66;03m# Viewer will ignore **options if `data` is a Table or View.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m161\u001b[39m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mPerspectiveWidget\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mload\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mD:\\Anaconda\\envs\\week07\\Lib\\site-packages\\perspective\\viewer\\viewer.py:210\u001b[39m, in \u001b[36mPerspectiveViewer.load\u001b[39m\u001b[34m(self, data, **options)\u001b[39m\n\u001b[32m    208\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m    209\u001b[39m     client = perspective.Server().new_local_client()\n\u001b[32m--> \u001b[39m\u001b[32m210\u001b[39m     \u001b[38;5;28mself\u001b[39m._table = \u001b[43mclient\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtable\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[43m=\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    211\u001b[39m     \u001b[38;5;28mself\u001b[39m._client = client\n\u001b[32m    213\u001b[39m \u001b[38;5;66;03m# If the user does not set columns to show, synchronize viewer state\u001b[39;00m\n\u001b[32m    214\u001b[39m \u001b[38;5;66;03m# with dataset.\u001b[39;00m\n",
      "\u001b[31mValueError\u001b[39m: Unknown input type TypeId(0xa2ed08c824384bb500e5c2441768fa6a)"
     ]
    }
   ],
   "source": [
    "PerspectiveWidget(d1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "6d392020-61c2-49dd-bbac-a915b66798dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5_412, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>ts_code</th><th>symbol</th><th>name</th><th>area</th><th>industry</th><th>fullname</th><th>enname</th><th>cnspell</th><th>market</th><th>exchange</th><th>curr_type</th><th>list_status</th><th>list_date</th><th>delist_date</th><th>is_hs</th><th>act_name</th><th>act_ent_type</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>date</td><td>null</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;000001.SZ&quot;</td><td>&quot;000001&quot;</td><td>&quot;平安银行&quot;</td><td>&quot;深圳&quot;</td><td>&quot;银行&quot;</td><td>&quot;平安银行股份有限公司&quot;</td><td>&quot;Ping An Bank Co., Ltd.&quot;</td><td>&quot;payh&quot;</td><td>&quot;主板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>1991-04-03</td><td>null</td><td>&quot;S&quot;</td><td>&quot;无实际控制人&quot;</td><td>&quot;无&quot;</td></tr><tr><td>&quot;000002.SZ&quot;</td><td>&quot;000002&quot;</td><td>&quot;万科A&quot;</td><td>&quot;深圳&quot;</td><td>&quot;全国地产&quot;</td><td>&quot;万科企业股份有限公司&quot;</td><td>&quot;China Vanke Co.,Ltd.&quot;</td><td>&quot;wka&quot;</td><td>&quot;主板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>1991-01-29</td><td>null</td><td>&quot;S&quot;</td><td>&quot;深圳市人民政府国有资产监督管理委员会&quot;</td><td>&quot;地方国企&quot;</td></tr><tr><td>&quot;000004.SZ&quot;</td><td>&quot;000004&quot;</td><td>&quot;*ST国华&quot;</td><td>&quot;深圳&quot;</td><td>&quot;软件服务&quot;</td><td>&quot;深圳国华网安科技股份有限公司&quot;</td><td>&quot;Shenzhen Guohua Network Securi…</td><td>&quot;stgh&quot;</td><td>&quot;主板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>1991-01-14</td><td>null</td><td>&quot;N&quot;</td><td>&quot;李映彤&quot;</td><td>&quot;民营企业&quot;</td></tr><tr><td>&quot;000006.SZ&quot;</td><td>&quot;000006&quot;</td><td>&quot;深振业A&quot;</td><td>&quot;深圳&quot;</td><td>&quot;区域地产&quot;</td><td>&quot;深圳市振业(集团)股份有限公司&quot;</td><td>&quot;Shenzhen Zhenye(Group) Co., Lt…</td><td>&quot;szya&quot;</td><td>&quot;主板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>1992-04-27</td><td>null</td><td>&quot;S&quot;</td><td>&quot;深圳市人民政府国有资产监督管理委员会&quot;</td><td>&quot;地方国企&quot;</td></tr><tr><td>&quot;000007.SZ&quot;</td><td>&quot;000007&quot;</td><td>&quot;全新好&quot;</td><td>&quot;深圳&quot;</td><td>&quot;其他商业&quot;</td><td>&quot;深圳市全新好股份有限公司&quot;</td><td>&quot;Shenzhen Quanxinhao Co,.Ltd.&quot;</td><td>&quot;qxh&quot;</td><td>&quot;主板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>1992-04-13</td><td>null</td><td>&quot;N&quot;</td><td>&quot;王玩虹&quot;</td><td>&quot;民营企业&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;920489.BJ&quot;</td><td>&quot;920489&quot;</td><td>&quot;佳先股份&quot;</td><td>null</td><td>null</td><td>&quot;安徽佳先功能助剂股份有限公司&quot;</td><td>&quot;Anhui Jiaxian Functional Auxil…</td><td>&quot;jxgf&quot;</td><td>&quot;北交所&quot;</td><td>&quot;BSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2020-07-27</td><td>null</td><td>&quot;N&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;920682.BJ&quot;</td><td>&quot;920682&quot;</td><td>&quot;球冠电缆&quot;</td><td>null</td><td>null</td><td>&quot;宁波球冠电缆股份有限公司&quot;</td><td>&quot;Ningbo Qrunning Cable Co.,Ltd&quot;</td><td>&quot;qgdl&quot;</td><td>&quot;北交所&quot;</td><td>&quot;BSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2020-07-27</td><td>null</td><td>&quot;N&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;920799.BJ&quot;</td><td>&quot;920799&quot;</td><td>&quot;艾融软件&quot;</td><td>null</td><td>null</td><td>&quot;上海艾融软件股份有限公司&quot;</td><td>&quot;Shanghai I2finance Technology …</td><td>&quot;arrj&quot;</td><td>&quot;北交所&quot;</td><td>&quot;BSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2020-07-27</td><td>null</td><td>&quot;N&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;920819.BJ&quot;</td><td>&quot;920819&quot;</td><td>&quot;颖泰生物&quot;</td><td>null</td><td>null</td><td>&quot;北京颖泰嘉和生物科技股份有限公司&quot;</td><td>&quot;Nutrichem Company Limited&quot;</td><td>&quot;ytsw&quot;</td><td>&quot;北交所&quot;</td><td>&quot;BSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2020-07-27</td><td>null</td><td>&quot;N&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;689009.SH&quot;</td><td>&quot;689009&quot;</td><td>&quot;九号公司-WD&quot;</td><td>&quot;北京&quot;</td><td>&quot;摩托车&quot;</td><td>&quot;九号有限公司&quot;</td><td>&quot;Ninebot Limited&quot;</td><td>&quot;jhgs&quot;</td><td>&quot;科创板&quot;</td><td>&quot;SSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2020-10-29</td><td>null</td><td>null</td><td>null</td><td>null</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5_412, 17)\n",
       "┌───────────┬────────┬─────────────┬──────┬───┬─────────────┬───────┬─────────────────────────────────┬──────────────┐\n",
       "│ ts_code   ┆ symbol ┆ name        ┆ area ┆ … ┆ delist_date ┆ is_hs ┆ act_name                        ┆ act_ent_type │\n",
       "│ ---       ┆ ---    ┆ ---         ┆ ---  ┆   ┆ ---         ┆ ---   ┆ ---                             ┆ ---          │\n",
       "│ str       ┆ str    ┆ str         ┆ str  ┆   ┆ null        ┆ str   ┆ str                             ┆ str          │\n",
       "╞═══════════╪════════╪═════════════╪══════╪═══╪═════════════╪═══════╪═════════════════════════════════╪══════════════╡\n",
       "│ 000001.SZ ┆ 000001 ┆ 平安银行    ┆ 深圳 ┆ … ┆ null        ┆ S     ┆ 无实际控制人                    ┆ 无           │\n",
       "│ 000002.SZ ┆ 000002 ┆ 万科A       ┆ 深圳 ┆ … ┆ null        ┆ S     ┆ 深圳市人民政府国有资产监督管理  ┆ 地方国企     │\n",
       "│           ┆        ┆             ┆      ┆   ┆             ┆       ┆ 委员会                          ┆              │\n",
       "│ 000004.SZ ┆ 000004 ┆ *ST国华     ┆ 深圳 ┆ … ┆ null        ┆ N     ┆ 李映彤                          ┆ 民营企业     │\n",
       "│ 000006.SZ ┆ 000006 ┆ 深振业A     ┆ 深圳 ┆ … ┆ null        ┆ S     ┆ 深圳市人民政府国有资产监督管理  ┆ 地方国企     │\n",
       "│           ┆        ┆             ┆      ┆   ┆             ┆       ┆ 委员会                          ┆              │\n",
       "│ 000007.SZ ┆ 000007 ┆ 全新好      ┆ 深圳 ┆ … ┆ null        ┆ N     ┆ 王玩虹                          ┆ 民营企业     │\n",
       "│ …         ┆ …      ┆ …           ┆ …    ┆ … ┆ …           ┆ …     ┆ …                               ┆ …            │\n",
       "│ 920489.BJ ┆ 920489 ┆ 佳先股份    ┆ null ┆ … ┆ null        ┆ N     ┆ null                            ┆ null         │\n",
       "│ 920682.BJ ┆ 920682 ┆ 球冠电缆    ┆ null ┆ … ┆ null        ┆ N     ┆ null                            ┆ null         │\n",
       "│ 920799.BJ ┆ 920799 ┆ 艾融软件    ┆ null ┆ … ┆ null        ┆ N     ┆ null                            ┆ null         │\n",
       "│ 920819.BJ ┆ 920819 ┆ 颖泰生物    ┆ null ┆ … ┆ null        ┆ N     ┆ null                            ┆ null         │\n",
       "│ 689009.SH ┆ 689009 ┆ 九号公司-WD ┆ 北京 ┆ … ┆ null        ┆ null  ┆ null                            ┆ null         │\n",
       "└───────────┴────────┴─────────────┴──────┴───┴─────────────┴───────┴─────────────────────────────────┴──────────────┘"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d1\n",
    "d2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ff467470-38a0-4dec-98e3-8a12aa267d44",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
